package com.ss.android.account.activity;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import com.ss.android.account.c.b;
import com.ss.android.newmedia.activity.BaseActivity;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelmsg.SendAuth.Resp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

public class aa extends BaseActivity implements IWXAPIEventHandler {
    private b a;

    public aa() {
        this.a = new b(this);
    }

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        IWXAPI v0 = null;
        String v1 = com.ss.android.account.bb.a().e();
        if (!TextUtils.isEmpty(((CharSequence) v1))) {
            v0 = WXAPIFactory.createWXAPI(((Context) this), v1, true);
        }

        if (v0 != null) {
            v0.handleIntent(this.getIntent(), ((IWXAPIEventHandler) this));
        }

        this.finish();
    }

    public void onReq(BaseReq arg1) {
    }

    public void onResp(BaseResp arg8) {
        if (1 == arg8.getType() && ((arg8 instanceof Resp))) {
            b v1 = this.a;
            if (arg8 == null) {
                v1.a();
                android.support.design.a.a(false, "");
            } else if (((Resp) arg8).errCode == 0) {
                String v2 = ((Resp) arg8).code;
                try {
                    if (TextUtils.isEmpty(v2)) {
                    } else {
                        v1.a.isDestroyed();
                        android.support.design.a.a(true, v2);
                        this.finish();
                        return;
                    }
                } catch (Exception v0) {
                    Log.w("weixin", "weixin sso exception: " + v0);
                }

                v1.a();
                android.support.design.a.a(false, v2);
            } else {
                v1.a();
                android.support.design.a.a(false, "");
            }

            this.finish();
        }
    }
}

